package modules

import (
	beego "github.com/beego/beego/v2/server/web"
	advert "ksd-social-api/modules/advert/router"
	channel "ksd-social-api/modules/channel/router"
	_ "ksd-social-api/modules/common/aliplayer/router"
	_ "ksd-social-api/modules/common/code/router"
	_ "ksd-social-api/modules/common/oss/router"
	pay "ksd-social-api/modules/common/pay/router"
	_ "ksd-social-api/modules/common/sms/router"
	_ "ksd-social-api/modules/common/upload/router"
	_ "ksd-social-api/modules/common/wxgzlogin/router"
	web "ksd-social-api/modules/login/controller"
	login "ksd-social-api/modules/login/router"
	msg "ksd-social-api/modules/msg/router"
	note "ksd-social-api/modules/note/router"
	platform "ksd-social-api/modules/platform/router"
	resume "ksd-social-api/modules/resume/router"
	skeys "ksd-social-api/modules/searchkeywords/router"
	special "ksd-social-api/modules/special/router"
	user "ksd-social-api/modules/user/router"
)

func init() {
	// 用户路由
	userRouter := user.UserRouter{}
	// 消息路由
	msgRouter := msg.MessageRouter{}
	// 登录路由
	loginRouter := login.LoginRouter{}
	// 广告路由
	advertRouter := advert.AdvertRouter{}
	// 支付路由
	payRouter := pay.PayRouter{}
	// 系统路由
	platformRouter := platform.PlatformSystemRouter{}
	// 栏目路由
	channelRouter := channel.ChannelRouter{}
	// 课程路由
	noteRouter := note.NoteRouter{}
	// 专栏路由
	specialRouter := special.SpecialRouter{}
	// 简历路由
	resumeRouter := resume.ResumeRouter{}
	// 关键词
	searchKeyRouter := skeys.SearchKeywordsRouter{}
	// 生成token
	beego.CtrlPost("/create/token", (*web.LoginController).CreateSecurityToken)

	// 不登录
	nons := beego.NewNamespace("/api",
		// 不需要登录
		userRouter.InitNoLoginRouter(),
		msgRouter.InitNoLoginRouter(),
		advertRouter.InitNoLoginRouter(),
		loginRouter.InitNoLoginRouter(),
		payRouter.InitNoLoginRouter(),
		platformRouter.InitNoLoginRouter(),
		channelRouter.InitNoLoginRouter(),
		noteRouter.InitNoLoginRouter(),
		specialRouter.InitNoLoginRouter(),
		resumeRouter.InitNoLoginRouter(),
		searchKeyRouter.InitNoLoginRouter(),
	)

	// 登录
	ns := beego.NewNamespace("/api/v1",
		loginRouter.InitRouter(),
		userRouter.InitRouter(),
		msgRouter.InitRouter(),
		advertRouter.InitRouter(),
		payRouter.InitRouter(),
		platformRouter.InitRouter(),
		channelRouter.InitRouter(),
		noteRouter.InitRouter(),
		specialRouter.InitRouter(),
		resumeRouter.InitRouter(),
		searchKeyRouter.InitRouter(),

		userRouter.InitAdminRouter(),
		specialRouter.InitAdminRouter(),
		resumeRouter.InitAdminRouter(),
		noteRouter.InitAdminRouter(),
		channelRouter.InitAdminRouter(),
	)

	// 命名空间注册
	beego.AddNamespace(nons)
	beego.AddNamespace(ns)
}
